package tegneprogram;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;

/**
 *
 * @author Franz
 */
public class Oval {

    private Point point1;
    private Point point2;
    private int xWidth;
    private int height;
    private Color c;

    public Oval(Point point1, Point point2, Color c) {

        this.c = c;

        if (point1.x > point2.x && point1.y > point2.y) {
            this.point1 = point2;
            this.point2 = point1;
        } else if (point1.x < point2.x && point1.y > point2.y) {
            this.point1 = new Point(point1.x, point2.y);
            this.point2 = new Point(point2.x, point1.y);
        } else if (point1.x > point2.x && point1.y < point2.y) {
            this.point1 = new Point(point2.x, point1.y);
            this.point2 = new Point(point1.x, point2.y);
        } else{
            this.point1 = point1;
            this.point2 = point2;
        }


        if (point2.x > point1.x) {
            xWidth = point2.x - point1.x;

        } else {
            xWidth = point1.x - point2.x;

        }
        if (point2.y > point1.y) {
            height = point2.y - point1.y;

        } else {
            height = point1.y - point2.y;

        }





    }

    public void draw(Graphics g) {
        g.setColor(c);

        g.fillOval(point1.x, point1.y, xWidth, height);
    }

    @Override
    public String toString() {
        return "2," + point1.x + "," + point1.y + "," + point2.x + "," + point2.y + "," + c.getRGB();
    }
}
